package inferenceEngine;

import static org.junit.Assert.*;
import inferenceEngine.labels.Label;
import inferenceEngine.types.Inference;
import inferenceEngine.types.Meaning;

import java.sql.ResultSet;
import java.util.ArrayList;

import org.junit.Test;

import common.Pair;
import common.SqliteManager;

public class TestInference {

	@Test
	public void test() {
		try {
			InferenceEngine engine = new InferenceEngine();
			ArrayList<Label> array = new ArrayList<Label>();
//			array.add( new Label ("ultraportable") );
			array.add( new Label( "ultraportable" ) );
			array.add( new Label( "detailed games" ) );
			array.add( new Label ("good processing capacity") );
			engine.infer(array,0,100000);
			String sql = engine.getBasicSql();
			sql = "select * from laptopView where " + sql;
			System.out.println(sql);
			
//			ArrayList<Label> labels1 = engine.getRecommendedLabels();
//			for( Label label : labels1 ){
//				System.out.println( label );
//			}
			
			ResultSet set = SqliteManager.getResult(sql);
			SqliteManager.displayResults(set);
			
			for( Pair<String,Label> result: engine.getRecommendedSql() ){
				System.out.println( result.first );
				System.out.println( result.second );
			}
			
			System.out.println();
			System.out.println("portable");
			for( Inference infer : engine.getFiredInferences() ){
				System.out.println( infer );
			}
			for( Meaning meaning : engine.getFiredMeanings() ){
				System.out.println( meaning );
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
	

}
